package com.sl.debug;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class Log {

    public static final Log log;

    static {
        try {
            log = new Log();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public Log() throws IOException {
        File file = FileUtil.file("./debug.log");
        if (FileUtil.exist(file)) {
            FileUtil.del(file);
        }
        file.createNewFile();
    }

    public void info(String str) {
        List<String> lists = new ArrayList<>();
        lists.add(str);
        FileUtil.appendLines(lists, "./debug.log", Charset.defaultCharset());
    }
}
